class Solution
{
public:
    int commonFactors(int a, int b)
    {
        int commonFactorCount = 0;
        for (int i = min(a, b); i > 0; --i)
        {
            if (a % i == 0 && b % i == 0)
            {
                ++commonFactorCount;
            }
        }
        return commonFactorCount;
    }
};